﻿package com.schimanek.navigation.tree 
{
	
	/**
	 * ...
	 * @author Gregor Schimanek
	 */
	public class ATreeController 
	{
		private var rootNode:ATreeNode;
		
		public function ATreeController(rootNode:ATreeNode) 
		{
			this.rootNode = rootNode;
		}
		
		public function getNodeByPath(path:String,limiter:String):ATreeNode {
			var id:String = path.slice(0, path.indexOf(limiter));
			trace("ID:" +id);
			//var nxt:ATreeNode=
			var node:ATreeNode=rootNode
			
			searchNode(id,node)
			
		}
		public function searchNode(nodeID:String, parent:ATreeNode,recursive:Boolean=true):ATreeNode {
			
			var nxt:ATreeNode = parent.aChildren[0] as ATreeNode;			
			while (nxt!=null) {
				if (nxt.id == nodeID) {
					break;
				}else{
					nxt = nxt.nextNode;
				}
			}
			if(recursive 
			return nxt
		}
		
	}
	
}